package cn.tradewin.advisor.pages.master;

import java.util.List;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

import cn.tradewin.advisor.persist.model.CalendarCategory;
import cn.tradewin.advisor.persist.services.CalendarService;

public class CalendarCategoryBoard {
	
	@Property
	private List<CalendarCategory> categories;
	
	@Property
	private CalendarCategory category;
	
	@Inject
	private BeanModelSource beanModelSource;
	
	@Property
	private BeanModel<CalendarCategory> beanModel;
	
	@Inject
	private Messages messages;
	
	@Inject
	private CalendarService calendarService;
	
	void setupRender() {
		beanModel = beanModelSource.createDisplayModel(CalendarCategory.class, messages);
		beanModel.add("action", null);
		beanModel.include("id", "name", "localeName", "action");
		beanModel.get("id").sortable(false);
		beanModel.get("name").sortable(false);
		beanModel.get("localeName").sortable(false);
		beanModel.get("action").sortable(false);
		categories = calendarService.getCalendarAllCategory();
	}
	
	void onDelete(String id) {
		calendarService.delCalendarCategory(new Byte(id));
	}
}
